package org.example.lotterysystem.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.example.lotterysystem.common.errorcode.ErrorCode;

/**
 * @author 十三
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException{
    /**
     * 异常码
     * @see org.example.lotterysystem.common.errorcode.ControllerErrorCodeConstants
     */
    private Integer code;
    /**
     * 异常消息
     */
    private String message;

    //为了序列化,必须要有一个无参的构造方法
    public ControllerException(){

    }
    public ControllerException(Integer code,String msg){
        this.code=code;
        this.message=msg;
    }
    public ControllerException(ErrorCode errorCode){
        this.code=errorCode.getCode();
        this.message=errorCode.getMsg();
    }
}
